#!/usr/bin/python # -*- coding: utf-8 -*- from __future__ import division # biblio https://engees.unistra.fr/fileadmin/user_upload/pdf/gsp/Cours_MCDA_AN.pdf Criteres = [ 'g%d'%i for i in range(1,10) ] Poids = [3, 3, 2, 2, 2, 1, 1, 1, 2] Poids = dict(zip(Criteres, map(lambda p: p/sum(Poids), Poids))) Actions = [ 'a1', 'a2', 'a3' ] Performances = { 'a1': dict(zip(Criteres, [4, 15.0, 10, 8, 3, 2, 2, 3, 2])), 'a2': dict(zip(Criteres, [3, 10.5, 7, 9, 3, 3, 3, 1, 3])), 'a3': dict(zip(Criteres, [2, 5.0, 11, 12, 2, 3, 2, 2, 3])) } Classes = ['Mauvais', 'Moyen', 'Bon' ] Seuils = { # seuils (g,q,p,v) de Mauvais à Moyen 'Mauvais': { 'g1': ( 2.0, 0.0, 0.0, 5), 'g2': ( 8.0, 0.5, 1.0, 10), 'g3': ( 8.0, 0.5, 1.0, 10), 'g4': ( 8.0, 0.5, 1.0, 10), 'g5': ( 2.0, 0.0, 0.0, 4), 'g6': ( 1.0, 0.0, 0.0, 3), 'g7': ( 2.0, 0.0, 0.0, 3), 'g8': ( 2.0, 0.0, 0.0, 4), 'g9': ( 2.0, 0.0, 0.0, 3) }, # seuils (g,q,p,v) de Moyen à Bon 'Moyen': { 'g1': ( 3.0, 1.0, 1.0, 5), 'g2': (13.0, 1.0, 3.0, 10), 'g3': (11.0, 1.0, 3.0, 10), 'g4': (12.0, 1.0, 3.0, 10), 'g5': ( 3.0, 0.0, 0.0, 4), 'g6': ( 2.0, 0.0, 0.0, 3), 'g7': ( 3.0, 0.0, 0.0, 3), 'g8': ( 3.0, 0.0, 0.0, 4), 'g9': ( 3.0, 0.0, 0.0, 3) } } Lambda = 0.75 def Concordance(a, bh): conc = 0.0 for critere in Criteres: poids = Poids[critere] ga = Performances[a][critere] gbh,qbh,pbh,vbh = Seuils[bh][critere] if ga <= gbh - qbh: c = 0.0 elif ga >= gbh + pbh: c = 1.0 else: c = (ga - (gbh - qbh)) / (pbh + qbh) conc += c * poids return conc for action in Actions: print action, for classe in Classes[:-1]: print classe, Concordance(action, classe), print def DiscordanceCritere(a, bh, critere): ga = Performances[a][critere] gbh,qbh,pbh,vbh = Seuils[bh][critere] if ga <= gbh - vbh: return 1.0 elif ga >= gbh + pbh: return 0.0 else: return ((gbh + pbh) - ga) / (pbh + vbh)